package com.pingbu.tijian.hospital.backapi.api;


import com.pingbu.common.bean.ResultBean;
import com.pingbu.common.utils.PbTimeUtils;
import com.pingbu.tijian.hospital.backapi.service.KspwStudentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@CrossOrigin
@RestController
@RequestMapping("/kspw_student")
public class KspwStudentController {

    private static final Logger logger = LoggerFactory.getLogger(KspwStudentController.class);

    @Autowired
    private KspwStudentService kspwStudentService;

    /**
     * 从excel导入学生
     * @return
     */
    @GetMapping(value = "/runImportStudent")
    public ResultBean runImportStudent(){
        kspwStudentService.importStudentExcel();
        return ResultBean.create(0,"学生导入完成 - "+ PbTimeUtils.formatTime(new Date(),"HH:mm:ss"));
    }

    @GetMapping(value = "/runRefreshRoomSeat")
    public ResultBean runRefreshRoomSeat(){
        logger.warn("测试一下 runRefreshRoomSeat，看看行不行。");
        kspwStudentService.refreshRoomSeat();
        return  ResultBean.create(0,"刷新各教室座位完成 - "+ PbTimeUtils.formatTime(new Date(),"HH:mm:ss"));
    }

    @GetMapping(value = "/runRefreshStudentSeat")
    public ResultBean runRefreshStudentSeat(){
        logger.warn("测试一下 runRefreshStudentSeat，看看行不行。");
        kspwStudentService.refreshStudentSeat();
        return  ResultBean.create(0,"刷新所有学生的座位完成 - "+ PbTimeUtils.formatTime(new Date(),"HH:mm:ss"));
    }

    @GetMapping(value = "/runExportBanjiSeat")
    public ResultBean runExportBanjiSeat(){
        kspwStudentService.exportBanjiSeat();
        return  ResultBean.create(0,"导出座位完成 - "+ PbTimeUtils.formatTime(new Date(),"HH:mm:ss"));
    }


}
